/**
 * Created by json on 2016/8/18.
 */

$.last_show_gonggao = 0;
$.last_gonggao_text = "";
$.last_paomadeng_text = "";

var xlch = xlch || {};
var xzdd = xzdd || {};
var gbmj = gbmj || {};
var gdmj_jipinghu = gdmj_jipinghu || {};
var gdmj_tuidaohu = gdmj_tuidaohu || {};
var zjmj = zjmj || {};
var jhmj = jhmj || {};
var ynmj = ynmj || {};
var csmj = csmj || {};
var niuniu = niuniu || {};
var zjh = zjh || {};
var sg = sg || {};
var xjmj = xjmj || {};

dwc.DT_MainScene = cc.Scene.extend({
    sprite:null,
    ctor:function () {
        this._super();
        this.mainNode=ccs.load(dwc.g_arrGCRes.dt_main_json).node;
        this.addChild(this.mainNode);

        this.initMain(this.mainNode);
        this.initMusic();

        dwc.DT_Data_Login.m_uiDTScene = this;
        var that=this;
        cc.eventManager.addListener({
            event    : cc.EventListener.CUSTOM,
            eventName: "CHANGE_PLAYER_INFO",
            callback : function(event){
                that.refreshData();
            }
        }, this);
        cc.eventManager.addListener({
            event    : cc.EventListener.CUSTOM,
            eventName: "CHANGE_AVATAR",
            callback : function(event){
                that.reloadAvatar();
            }
        }, this);
        cc.eventManager.addListener({
            event : cc.EventListener.TOUCH_ONE_BY_ONE,
            swallowTouches : false,
            onTouchBegan : function(touch, event){ return that.onTouchBegan(touch, event); },
        }, this);

        this.loadRes();

        dwc.DT_Data_Login.sendUserChip();
        dwc.DT_Data_Login.sendUserRoom();

        this._checkMyRoom();
        this.schedule(this._checkMyRoom,1.0);

        if(!$.check_connect)
        {
            $.check_connect = setInterval(function()
            {
                if($.runningScene && dwc.DT_Data_Login.isConnected() == false)
                {
                    //dwc.DT_Data_Login.SendConnect();
                }
            },3000);
        }
        this.schedule(this._checkNetwork,1.0);


        var nowtime = Date.now();
        if(nowtime - $.last_show_gonggao > 12*3600*1000)
        {
            /*
            $.last_show_gonggao = nowtime;
            var gonggao_url = "http://app.cjpoker.com/gdmj/gonggao.txt";
            //网络请求
            dwc.GX_NetWorkManager.SendMessage(gonggao_url,
                function (_msg) {
                    try {
                        $.last_gonggao_text = _msg;
                        if($.last_gonggao_text)
                        {
                            var dlg=new dwc.MsgDialog();
                            that.addChild(dlg);
                            dlg.Show();
                        }
                    }catch (e)
                    {

                    }
                });
            */
            /*
            $.last_show_paomadeng = nowtime;
            var pmd_url = "http://app.cjpoker.com/gdmj/pmd.txt";
            //网络请求
            dwc.GX_NetWorkManager.SendMessage(pmd_url,
                function (_msg) {
                    try {
                        $.last_show_paomadeng = _msg;
                        if($.last_show_paomadeng)
                        {
                            that.gonggaoLabel.setString(_msg);
                        }
                    }catch (e)
                    {

                    }
                });
             */
        }


    },


    loadRes : function()
    {
        var that = this;
        dwc.DT_Data_Login.sendUserRoom();

    },
    _checkMyRoom : function()
    {
        var myRoom = dwc.Myself.GetMyRoom();
        if(myRoom)
        {
            this.cjfjLayout.setVisible(false);
            this.fhfjLayout.setVisible(true);
        }else{
            this.cjfjLayout.setVisible(true);
            this.fhfjLayout.setVisible(false);
        }
    },
    _checkNetwork : function()
    {
        if(dwc.DT_Data_Login.isConnected() == false)
        {
            this.unschedule(this._checkNetwork);

            var alert=new dwc.PopupAlert("网络连接已中断，重新登录可继续游戏",function()
            {
                cc.director.runScene(new dwc.LoginScene());
            });
            this.addChild(alert);
            alert.Show();
        }
    },
    initMain: function (mainNode) {
        var bAliPay = $.getItem("bAliPay");
        var that=this;
        //聊天
        this.headImage = $.getNodeByName(mainNode, "ID_IMAGEVIEW_HEADIMAGE");

        //提示
        //this.hintBack=$.getNodeByName(mainNode,"ID_SPRITE_HINT_MSG");
        //this.hintBack.setVisible(false);
        //this.hintLabel=$.getNodeByName(mainNode,"ID_LABEL_HINTLABEL");

        this.showLoadingNode =  $.getNodeByName(mainNode,"ID_LAYOUT_LOADING");
        this.spLoading =  $.getNodeByName(mainNode,"ID_SPRITE_LOADING");
        this.spTouZi =  $.getNodeByName(mainNode,"ID_SPRITE_TOUZI");
        this.initLoadingEffect();
        this.ShowLoading(false);

        var logo =$.getNodeByName(mainNode,"ID_SPRITE_LOGO");
        var bundle = $.getBundleID();
        if(bundle == "com.cjpoker.xlch")
        {
            logo.initWithFile("res/image/logo_title_xlch.png");
        }
        if(bundle == "com.cjpoker.ycxl")
        {
            logo.initWithFile("res/image/logo_title_ycxl.png");
        }
        this.gonggaoLabel=$.getNodeByName(mainNode,"ID_LABEL_GONGGAO");
        //if(bAliPay == "true") {
            //this.gonggaoLabel.setString("代理联系:微信27665166");
            //this.gonggaoLabel.setString("代理请加官方微信：27665166，财神麻将公测期间不扣 ");
        //}
        that.gonggaoLabel.runAction(cc.sequence(cc.moveTo(15,cc.p(-760,0)),cc.callFunc(function () {
            that.gonggaoLabel.setPosition(760,0);
        },that)).repeatForever());
        //提示
        this.hintBack=$.getNodeByName(mainNode,"ID_SPRITE_HINT_MSG");
        this.hintBack.setVisible(false);
        this.hintLabel=$.getNodeByName(mainNode,"ID_LABEL_HINTLABEL");

        this.headImage.addClickEventListener(function () {
            that.OnClickHeadImage();
        });
        this.nickname=$.getNodeByName(mainNode,"ID_LABEL_NICKNAME");
        this.nickname.setString(dwc.Myself.GetData().GetNickName());

        this.uidLabel=$.getNodeByName(mainNode,"ID_LABEL_UID");
        this.uidLabel.setString("ID: " + dwc.Myself.GetData().GetUid());

        this.gemLabel=$.getNodeByName(mainNode,"ID_LABEL_GEM");
        this.gemLabel.setString(dwc.Myself.GetData().GetGem());



        this.userInfoLayout=$.getNodeByName(mainNode,"ID_LAYOUT_USERINFO");
        this.userInfoLayout.addClickEventListener(function () {
            that.userInfoLayout.setVisible(false);
        });
        this.userInfoLayout.setVisible(false);

        this.userInfoHeadImg=$.getNodeByName(mainNode,"ID_SPRITE_USERHEADIMG");
        this.useridLabel=$.getNodeByName(mainNode,"ID_LABEL_USERID");
        this.useridLabel.setString("ID: " + dwc.Myself.GetData().GetUid());

        this.usernickLabel=$.getNodeByName(mainNode,"ID_LABEL_USERNICK");
        this.usernickLabel.setString("" + dwc.Myself.GetData().GetNickName());

        this.useripLabel=$.getNodeByName(mainNode,"ID_LABEL_USERIP");
        this.useripLabel.setString("IP: " + dwc.Myself.GetData().GetIP());

        this.cjfjLayout=$.getNodeByName(mainNode,"ID_LAYOUT_CJFJ");
        this.cjfjLayout.addClickEventListener(function () {
       //     cc.director.runScene(new jhmj.mj_playback(null));
//			var alert = new jhmj.mj_playback(null);
//			$.runningScene.addChild(alert);
//			alert.Show();
			
 //           return;
            var myRoom = dwc.Myself.GetMyRoom();
            if(myRoom == null || myRoom == undefined)
            {
                var dlg=new dwc.CreateRoomDialog(that);
                that.addChild(dlg);
                dlg.Show();
                cc.audioEngine.playEffect("res/audio/pop.wav",false);
            }else{
                that.OnFanHuiRoom();
                cc.audioEngine.playEffect("res/audio/pop.wav",false);
            }
        });
        this.fhfjLayout=$.getNodeByName(mainNode,"ID_LAYOUT_FHFJ");
        this.fhfjLayout.addClickEventListener(function () {
            that.OnFanHuiRoom();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });
        this.fhfjLayout.setVisible(false);

        this.jrfjLayout=$.getNodeByName(mainNode,"ID_LAYOUT_JRFJ");
        this.jrfjLayout.addClickEventListener(function () {
            if(dwc.Myself.GetMyRoom())
            {
                that.OnFanHuiRoom();
                return;
            }

            var dlg=new dwc.JoinRoomDialog(that);
            that.addChild(dlg);
            dlg.Show();

            //that.OnShowHint("您有一局未结束，不能加入其它房间！");
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });

        this.huodongBtn=$.getNodeByName(mainNode,"ID_BUTTON_HUODONG");
        this.huodongBtn.addClickEventListener(function () {

            var dlg=new dwc.BaoMingDialog(that);
            that.addChild(dlg);
            dlg.Show();

            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });


        this.settingBtn=$.getNodeByName(mainNode,"ID_BUTTON_SETTING");
        this.settingBtn.addClickEventListener(function () {
            var dlg=new dwc.SettingDialog(that);
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });
        this.helpBtn=$.getNodeByName(mainNode,"ID_BUTTON_HELP");
        this.helpBtn.addClickEventListener(function () {
            var dlg=new dwc.HelpDialog(that);
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });
        this.tuiguangBtn=$.getNodeByName(mainNode,"ID_BUTTON_TUIGUANG");
        this.tuiguangBtn.addClickEventListener(function () {
            var dlg=new dwc.DT_Shop();
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });
        this.dailiBtn=$.getNodeByName(mainNode,"ID_BUTTON_DAILI");
        this.dailiBtn.addClickEventListener(function () {
            if(cc.sys.isNative)
            {
                cc.sys.openURL("http://zjmj.cjpoker.com");
            }
            /*
            var dlg=new dwc.DaiLiDialog();
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
            */
        });

        this.msgBtn=$.getNodeByName(mainNode,"ID_BUTTON_MSG");
        this.msgBtn.addClickEventListener(function () {
            var dlg=new dwc.MsgDialog();
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });
        this.zhanjiBtn=$.getNodeByName(mainNode,"ID_BUTTON_ZHANJI");
        this.zhanjiBtn.addClickEventListener(function () {
            var dlg=new dwc.ZhanJiDialog(that);
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });
        this.shareBtn=$.getNodeByName(mainNode,"ID_BUTTON_SHARE");
        this.shareBtn.addClickEventListener(function () {
            var dlg=new dwc.ShareDialog(that);
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });
    //房间管理
        this.fjglBtn=$.getNodeByName(mainNode,"ID_BUTTON_FJGL");
        this.fjglBtn.addClickEventListener(function () {
            var dlg=new dwc.DLRoomManagerDialog(that);
            that.addChild(dlg);
            dlg.Show();
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        });

        this.buycardBtn=$.getNodeByName(mainNode,"ID_BUTTON_BUYCARD");
        this.buycardLayout=$.getNodeByName(mainNode,"ID_LAYOUT_BUYCARD");
        this.buycardLayoutOK=$.getNodeByName(mainNode,"ID_LAYOUT_BUYCARD_OK");
        this.buycardLayoutCancel=$.getNodeByName(mainNode,"ID_LAYOUT_BUYCARD_CANCEL");
        this.buycardLayout.setVisible(false);
        this.buycardBtn.addClickEventListener(function () {
            if(bAliPay == "true")
            {
                var dlg=new dwc.DaiLiDialog(that);
                that.addChild(dlg);
                dlg.Show();
            }else{
                that.buycardLayout.setVisible(true);
            }that.buycardLayout.setVisible(true);

        });
        this.buycardLayoutOK.addClickEventListener(function () {
            that.buycardLayout.setVisible(false);
            that.OnBuyCard();
        });
        this.buycardLayoutCancel.addClickEventListener(function () {
            that.buycardLayout.setVisible(false);
        });
        this.shopBtn=$.getNodeByName(mainNode,"ID_BUTTON_SHOP");
        this.shopBtn.addClickEventListener(function () {
            var dlg=new dwc.DT_Shop();
            that.addChild(dlg);
            dlg.Show();
        });

        this.spGG = $.getNodeByName(mainNode,"ID_SPRITE_GG");
        this.wxfkBack = $.getNodeByName(mainNode,"ID_LAYOUT_WXFKBG");
        this.wxfkBtn=$.getNodeByName(mainNode,"ID_BUTTON_WYFK");
        this.wxfkBtn.addClickEventListener(function () {
            this.wxfkBack.setVisible(true);
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        }.bind(this));
        this.wxfkBack.setVisible(false);

        this.wxfkCloseBtn=$.getNodeByName(mainNode,"ID_BUTTON_WXFKCLOSE");
        this.wxfkCloseBtn.addClickEventListener(function () {
            this.wxfkBack.setVisible(false);
            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        }.bind(this));

        this.yqylBtn=$.getNodeByName(mainNode,"ID_BUTTON_YQYL");
        this.yqylBtn.addClickEventListener(function () {

            cc.audioEngine.playEffect("res/audio/pop.wav",false);
        }.bind(this));
        this.yqylBtn.setVisible(false);

        if(bAliPay == "true") {
            this.buycardBtn.setVisible(false);
            this.shopBtn.setVisible(true);
            this.tuiguangBtn.setVisible(true);
        }else{
            this.buycardBtn.setVisible(true);
            //this.shopBtn.setVisible(false);
            this.tuiguangBtn.setVisible(false);
            this.spGG.setVisible(false);
            this.wxfkBtn.setVisible(false);
            this.dailiBtn.setVisible(false);
        }
        this.refreshData();
        this.reloadAvatar();
    },
    OnBuyCard : function()
    {
        var that = this;
        if (cc.sys.os == cc.sys.OS_IOS) {
            var bundleID = $.getBundleID();
            var item_id = "ITEM_GEM_30";
            var price = 30 * 100;//ping++以分计算
            var product_id = "com.cjpoker.xlch.iap_01";
            if (bundleID == "com.cjpoker.xlch") {
                product_id = "com.cjpoker.xlch.iap_01";
            }
            if (bundleID == "com.cjpoker.zujumj") {
                product_id = "com.cjpoker.zujumj.iap_01";
            }
            if (bundleID == "com.cjpoker.cqmj") {
                product_id = "com.cjpoker.cqmj.iap_01";
            }
            if (bundleID == "com.cjpoker.gdmj") {
                product_id = "com.cjpoker.gdmj.iap_01";
            }
            if (bundleID == "com.cjpoker.zjmj") {
                product_id = "com.cjpoker.zjmj.iap_01";
            }
            var UID = $.uid + "";
            var payMessage = jsb.reflection.callStaticMethod(
                "RootViewController",
                "payWithWay:andMoney:andUser:andToUser:andURL:andItemID:andItemID2:",
                "iap",
                price,
                UID + "+" + 30,
                UID,
                "http://zjmj.cjpoker.com/app/pay/pay.php?a=ios_verifyreceipt",
                item_id, product_id);
        }
    },
    OnShowHint:function (content)
    {
        var that=this;
        this.hintLabel.setString(content);
        this.hintBack.stopAllActions();
        this.hintLabel.stopAllActions();
        this.hintBack.setVisible(true);
        this.hintLabel.setPosition(600,23);
        this.hintBack.runAction(cc.sequence(cc.delayTime(1.2),cc.callFunc(function () {
            that.hintBack.setVisible(false);
            that.hintLabel.setPosition(600,23);
        },this)))
        this.hintLabel.runAction(cc.moveTo(0.2,cc.p(600,75)));
    },
    initMusic : function()
    {
        cc.audioEngine.playMusic("res/audio/bgm2.mp3",true);


    },

    initLoadingEffect : function()
    {
        this.spLoading.runAction(cc.repeatForever(cc.rotateBy(1.5,360)));
    },
    ShowLoading : function(visible)
    {
        var that = this;
        this.showLoadingNode.setVisible(visible);
        if(visible)
        {
            this.scheduleOnce(function(){
                that.ShowLoading(false);
            },5.0);
        }
    },

    OnClickHeadImage: function () {
        //test /////////////////////////
        this.userInfoLayout.setVisible(true);
        this.usernickLabel.setString(dwc.Myself.GetData().GetNickName());
        this.useridLabel.setString("ID: "+dwc.Myself.GetData().GetUid());
        this.useripLabel.setString("IP: "+dwc.Myself.GetData().GetIP());
    },

    refreshData: function () {
        this.gemLabel.setString(dwc.Myself.GetData().GetGem());
        this.nickname.setString(dwc.Myself.GetData().GetNickName());
    },
    reloadAvatar: function()
    {
        if(dwc.Myself.GetData().GetUid() == dwc.Myself.GetData().GetAvatar())
        {
            var avatar_url= $.getMyAvatarUrl(dwc.Myself.GetData().GetUid(),dwc.Myself.GetData().GetSex());

            this.headImage.removeChildByTag(999,true);
            if(!this.headImage.getChildByTag(999)) {
                var param = {
                    avatar :  dwc.Myself.GetData().GetAvatar(),
                    gender :  dwc.Myself.GetData().GetSex(),
                    avatar_url :  avatar_url
                };
                dwc.GX_UserHeadImgManager.GetUrlImg(avatar_url, function (target, success, sprite,param) {
                    var headImageSprite = sprite;
                    if (success) {
                        headImageSprite.setScale(target.width / headImageSprite.width, target.height / headImageSprite.height);
                        headImageSprite.setAnchorPoint(cc.p(0.5, 0.5));
                        headImageSprite.setPosition(cc.p(target.width / 2, target.height / 2));
                        target.addChild(headImageSprite, 0, 999);
                    } else {
                        cc.log("get img error");
                        headImageSprite = new cc.Sprite($.getAvatarUrl(param.avatar, param.gender));
                        headImageSprite.setScale(target.width / headImageSprite.width, target.height / headImageSprite.height);
                        headImageSprite.setAnchorPoint(cc.p(0.5, 0.5));
                        headImageSprite.setPosition(cc.p(target.width / 2, target.height / 2));
                        target.addChild(headImageSprite, 0, 999);
                    }
                }, this.headImage,param);
            }
        }
    },
    OnFanHuiRoom : function()
    {
        var myRoom = dwc.Myself.GetMyRoom();
        if(myRoom)
        {
            dwc.DT_Data_Login.SendReturnRoom(myRoom.room_id);
        }
    },
    onEnter: function () {
        this._super();
        var that=this;
        $.runningScene = this;
        $.disconnect_notice = 0;

        dwc.DT_Data_Login.m_uiDTScene = this;

        this._checkMyRoom();

    },
    onTouchBegan: function () {
        var that=this;
        return true;
    },
    onExit: function () {
        this._super();
        $.runningScene = null;

        dwc.DT_Data_Login.m_uiDTScene = null;
    }
});

dwc.TuiDaoHu_Page = {
    roomType:"TUIDAOHU",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode){
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_TUIDAOHU");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");

        this.optGuiX0CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_GUIX0");
        this.optGuiX0CheckBox.addEventListener(function (sender,type) {
            that.OnGuiX0CheckBox(sender,type);
        },this);
        this.optGuiX0Text=$.getNodeByName(rootNode,"ID_LABEL_GUIX0_TEXT");

        this.optGuiX1CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_GUIX1");
        this.optGuiX1CheckBox.addEventListener(function (sender,type) {
            that.OnGuiX1CheckBox(sender,type);
        },this);
        this.optGuiX1Text=$.getNodeByName(rootNode,"ID_LABEL_GUIX1_TEXT");

        this.optGuiX2CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_GUIX2");
        this.optGuiX2CheckBox.addEventListener(function (sender,type) {
            that.OnGuiX2CheckBox(sender,type);
        },this);
        this.optGuiX2Text=$.getNodeByName(rootNode,"ID_LABEL_GUIX2_TEXT");

        this.optMaX0CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_MAX0");
        this.optMaX0CheckBox.addEventListener(function (sender,type) {
            that.OnMaX0CheckBox(sender,type);
        },this);
        this.optMaX0Text=$.getNodeByName(rootNode,"ID_LABEL_MAX0_TEXT");

        this.optMaX2CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_MAX2");
        this.optMaX2CheckBox.addEventListener(function (sender,type) {
            that.OnMaX2CheckBox(sender,type);
        },this);
        this.optMaX2Text=$.getNodeByName(rootNode,"ID_LABEL_MAX2_TEXT");

        this.optMaX6CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_MAX6");
        this.optMaX6CheckBox.addEventListener(function (sender,type) {
            that.OnMaX6CheckBox(sender,type);
        },this);
        this.optMaX6Text=$.getNodeByName(rootNode,"ID_LABEL_MAX6_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On8juCheckBox();
        this.OnGuiX0CheckBox();
        this.OnMaX6CheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {

        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="8JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="16JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.jushu="16JU";
        this.opt["16JU"] = true;
        delete this.opt["8JU"];
        cc.log(this.opt);

    },

    OnGuiX0CheckBox: function (sender , CheckBoxType) {
        this.optGuiX0CheckBox.setSelected(true);
        //this.optGuiX0Text.setColor(cc.color.GREEN);
        this.optGuiX1CheckBox.setSelected(false);
        //this.optGuiX1Text.setColor(cc.color.GREEN);
        this.optGuiX2CheckBox.setSelected(false);
        //this.optGuiX2Text.setColor(cc.color.GREEN);

        this.opt["GUIX0"] = true;
        delete this.opt["GUIX1"];
        delete this.opt["GUIX2"];
    },
    OnGuiX1CheckBox: function (sender , CheckBoxType) {
        this.optGuiX0CheckBox.setSelected(false);
        //this.optGuiX0Text.setColor(cc.color.GREEN);
        this.optGuiX1CheckBox.setSelected(true);
        //this.optGuiX1Text.setColor(cc.color.GREEN);
        this.optGuiX2CheckBox.setSelected(false);
        //this.optGuiX2Text.setColor(cc.color.GREEN);

        this.opt["GUIX1"] = true;
        delete this.opt["GUIX0"];
        delete this.opt["GUIX2"];
    },
    OnGuiX2CheckBox: function (sender , CheckBoxType) {
        this.optGuiX0CheckBox.setSelected(false);
        //this.optGuiX0Text.setColor(cc.color.GREEN);
        this.optGuiX1CheckBox.setSelected(false);
        //this.optGuiX1Text.setColor(cc.color.GREEN);
        this.optGuiX2CheckBox.setSelected(true);
        //this.optGuiX2Text.setColor(cc.color.GREEN)

        this.opt["GUIX2"] = true;
        delete this.opt["GUIX0"];
        delete this.opt["GUIX1"];
    },
    OnMaX0CheckBox: function (sender , CheckBoxType) {
        this.optMaX0CheckBox.setSelected(true);
        //this.optMaX0Text.setColor(cc.color.GREEN);
        this.optMaX2CheckBox.setSelected(false);
        //this.optMaX2Text.setColor(cc.color.GREEN);
        this.optMaX6CheckBox.setSelected(false);
        //this.optMaX6Text.setColor(cc.color.GREEN);

        this.opt["MAX0"] = true;
        delete this.opt["MAX2"];
        delete this.opt["MAX6"];
    },
    OnMaX2CheckBox: function (sender , CheckBoxType) {
        this.optMaX0CheckBox.setSelected(false);
        //this.optMaX0Text.setColor(cc.color.GREEN);
        this.optMaX2CheckBox.setSelected(true);
        //this.optMaX2Text.setColor(cc.color.GREEN);
        this.optMaX6CheckBox.setSelected(false);
        //this.optMaX6Text.setColor(cc.color.GREEN);

        this.opt["MAX2"] = true;
        delete this.opt["MAX0"];
        delete this.opt["MAX4"];
        delete this.opt["MAX6"];
    },
    OnMaX4CheckBox: function (sender , CheckBoxType) {
        this.optMaX0CheckBox.setSelected(false);
        //this.optMaX0Text.setColor(cc.color.GREEN);
        this.optMaX2CheckBox.setSelected(false);
        //this.optMaX2Text.setColor(cc.color.GREEN);
        this.optMaX6CheckBox.setSelected(false);
        //this.optMaX6Text.setColor(cc.color.GREEN);

        this.opt["MAX4"] = true;
        delete this.opt["MAX0"];
        delete this.opt["MAX4"];
        delete this.opt["MAX6"];
    },
    OnMaX6CheckBox: function (sender , CheckBoxType) {
        this.optMaX0CheckBox.setSelected(false);
        //this.optMaX0Text.setColor(cc.color.GREEN);
        this.optMaX2CheckBox.setSelected(false);
        //this.optMaX2Text.setColor(cc.color.GREEN);
        this.optMaX6CheckBox.setSelected(true);
        //this.optMaX6Text.setColor(cc.color.GREEN);

        this.opt["MAX6"] = true;
        delete this.opt["MAX0"];
        delete this.opt["MAX2"];
        delete this.opt["MAX4"];
    },
};
dwc.JIPINGHU_Page = {
    roomType:"JIPINGHU",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_JIPINGHU");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");

        this.optFANX0CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FANX0");
        this.optFANX0CheckBox.addEventListener(function (sender,type) {
            that.OnFANX0CheckBox(sender,type);
        },this);
        this.optFANX0Text=$.getNodeByName(rootNode,"ID_LABEL_FANX0_TEXT");

        this.optFANX1CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FANX1");
        this.optFANX1CheckBox.addEventListener(function (sender,type) {
            that.OnFANX1CheckBox(sender,type);
        },this);
        this.optFANX1Text=$.getNodeByName(rootNode,"ID_LABEL_FANX1_TEXT");

        this.optFANX3CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FANX3");
        this.optFANX3CheckBox.addEventListener(function (sender,type) {
            that.OnFANX3CheckBox(sender,type);
        },this);
        this.optFANX3Text=$.getNodeByName(rootNode,"ID_LABEL_FANX3_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On8juCheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="8JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="16JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.jushu="16JU";
        this.opt["16JU"] = true;
        delete this.opt["8JU"];
        cc.log(this.opt);

    },

    OnFANX0CheckBox: function (sender , CheckBoxType) {
        this.optFANX0CheckBox.setSelected(true);
        //this.optFANX0Text.setColor(cc.color.GREEN);
        this.optFANX1CheckBox.setSelected(false);
        //this.optFANX1Text.setColor(cc.color.GREEN);
        this.optFANX3CheckBox.setSelected(false);
        //this.optFANX3Text.setColor(cc.color.GREEN);

        this.opt["FANX0"] = true;
        delete this.opt["FANX1"];
        delete this.opt["FANX3"];
    },
    OnFANX1CheckBox: function (sender , CheckBoxType) {
        this.optFANX0CheckBox.setSelected(false);
        //this.optFANX0Text.setColor(cc.color.GREEN);
        this.optFANX1CheckBox.setSelected(true);
        //this.optFANX1Text.setColor(cc.color.GREEN);
        this.optFANX3CheckBox.setSelected(false);
        //this.optFANX3Text.setColor(cc.color.GREEN);

        this.opt["FANX1"] = true;
        delete this.opt["FANX0"];
        delete this.opt["FANX3"];
    },
    OnFANX3CheckBox: function (sender , CheckBoxType) {
        this.optFANX0CheckBox.setSelected(false);
        //this.optFANX0Text.setColor(cc.color.GREEN);
        this.optFANX1CheckBox.setSelected(false);
        //this.optFANX1Text.setColor(cc.color.GREEN);
        this.optFANX3CheckBox.setSelected(true);
        //this.optFANX3Text.setColor(cc.color.GREEN)

        this.opt["FANX3"] = true;
        delete this.opt["FANX0"];
        delete this.opt["FANX1"];
    },
};
dwc.GBMJ_Page = {
    roomType:"GBMJ",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_GBMJ");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On8juCheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="8JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="16JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.opt16juCheckBox.setSelected(false);

        //this.opt16juLabel.setColor(cc.color.WHITE);
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.jushu="16JU";
        this.opt["16JU"] = true;
        delete this.opt["8JU"];
        cc.log(this.opt);

    },
};
dwc.XLCH_Page = {
    roomType:"XLCH",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_XLCH");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt3juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_3JU");
        this.opt3juCheckBox.addEventListener(function (sender,type) {
            that.On3juCheckBox(sender,type);
        },this);
        this.opt3juLabel=$.getNodeByName(rootNode,"ID_LABEL_3JU_TEXT");

        this.opt6juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_6JU");
        this.opt6juCheckBox.addEventListener(function (sender,type) {
            that.On6juCheckBox(sender,type);
        },this);
        this.opt6juLabel=$.getNodeByName(rootNode,"ID_LABEL_6JU_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On3juCheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="3JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="6JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On3juCheckBox: function (sender , CheckBoxType) {
        this.opt3juCheckBox.setSelected(true);
        //this.opt3juLabel.setColor(cc.color.GREEN);
        this.opt6juCheckBox.setSelected(false);
        //this.opt6juLabel.setColor(cc.color.WHITE);
        this.jushu="3JU";
        this.opt["3JU"] = true;
        delete this.opt["6JU"];

    },
    On6juCheckBox: function (sender , CheckBoxType) {
        this.opt6juCheckBox.setSelected(true);
        //this.opt6juLabel.setColor(cc.color.GREEN);
        this.opt3juCheckBox.setSelected(false);
        //this.opt3juLabel.setColor(cc.color.WHITE);
        this.jushu="6JU";
        this.opt["6JU"] = true;
        delete this.opt["3JU"];
        cc.log(this.opt);

    },
};

dwc.JHMJ_Page = {
    roomType:"JHMJ",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_JHMJ");
        rootNode.setVisible(false);
        this.rootNode = rootNode;

        this.nodeFen = $.getNodeByName(rootNode,"ID_NODE_OPT_FEN");
        this.nodeFen.setVisible(false);

        this.nodeJU = $.getNodeByName(rootNode,"ID_NODE_OPT_JU");
        this.nodeJU.setVisible(false);

        this.optDaKunCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DAKUN");
        this.optDaKunCheckBox.addEventListener(function (sender,type) {
            that.OnDaKunCheckBox(sender,type);
        },this);
        this.optDaKunLabel=$.getNodeByName(rootNode,"ID_LABEL_DAKUN_TEXT");

        this.optChangPaoCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_CHANGPAO");
        this.optChangPaoCheckBox.addEventListener(function (sender,type) {
            that.OnChangPaoCheckBox(sender,type);
        },this);
        this.optChangPaoLabel=$.getNodeByName(rootNode,"ID_LABEL_CHANGPAO_TEXT");

        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");


        this.optDI36CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DI36");
        this.optDI36CheckBox.addEventListener(function (sender, type) {
            that.OnDI36CheckBox(sender,type);
        },this);
        this.optQiZhuang36Text=$.getNodeByName(rootNode,"ID_LABEL_DI36_TEXT");

        this.optDI48CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DI48");
        this.optDI48CheckBox.addEventListener(function (sender, type) {
            that.OnDI48CheckBox(sender,type);
        },this);
        this.optDI48Text=$.getNodeByName(rootNode,"ID_LABEL_DI48_TEXT");

        this.optFD40CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FD40");
        this.optFD40CheckBox.addEventListener(function (sender,type) {
            that.OnFD40CheckBox(sender,type);
        },this);
        this.optFD40Label=$.getNodeByName(rootNode,"ID_LABEL_FD40_TEXT");

        this.optFD50CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FD50");
        this.optFD50CheckBox.addEventListener(function (sender,type) {
            that.OnFD50CheckBox(sender,type);
        },this);
        this.optFD50Label=$.getNodeByName(rootNode,"ID_LABEL_FD50_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        //this.OnDaKunCheckBox();
        //this.On8juCheckBox();
        //this.OnDI36CheckBox();
        //this.OnFD40CheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.opt["4JU"])
        {
            minNumGem=1;
        }else  if(this.opt["8JU"])
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    //实际为4局选择
    OnDaKunCheckBox: function (sender , CheckBoxType) {
        this.optDaKunCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);

        this.optChangPaoCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);

        this.nodeFen.setVisible(true);
        this.nodeJU.setVisible(false);
        this.opt["4JU"] = true;
        delete this.opt["8JU"];

    },
    //实际为8局
    OnChangPaoCheckBox: function (sender , CheckBoxType) {
        this.optChangPaoCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);

        this.optDaKunCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.nodeFen.setVisible(false);
        this.nodeJU.setVisible(true);
        this.opt["8JU"] = true;
        delete this.opt["4JU"];

    },
    OnFD40CheckBox: function (sender , CheckBoxType)
    {
        this.optFD40CheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.optFD50CheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);

        this.opt["FD40"] = true;
        delete this.opt["FD50"];

    },
    OnFD50CheckBox: function (sender , CheckBoxType)
    {

        this.optFD50CheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.optFD40CheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);

        this.opt["FD50"] = true;
        delete this.opt["FD40"];

    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setTextColor(cc.color.RED);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setTextColor(cc.color.WHITE);

        this.opt["8JU"] = true;
        delete this.opt["16JU"];
    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setTextColor(cc.color.RED);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setTextColor(cc.color.WHITE);

        this.opt["16JU"] = true;
        delete this.opt["8JU"];
    },

    OnDI36CheckBox: function (sender , CheckBoxType) {
        this.optDI36CheckBox.setSelected(true);
        //this.optMoGuiText.setColor(cc.color.GREEN);
        this.optDI48CheckBox.setSelected(false);
        //this.optGuiX1Text.setColor(cc.color.GREEN);

        this.opt["CHI_PAI"] = true;
        delete this.opt["NO_CHI_PAI"];
    },
    OnDI48CheckBox: function (sender , CheckBoxType) {
        this.optDI36CheckBox.setSelected(false);
        //this.optMoGuiText.setColor(cc.color.GREEN);
        this.optDI48CheckBox.setSelected(true);
        //this.optGuiX1Text.setColor(cc.color.GREEN);

        this.opt["NO_CHI_PAI"] = true;
        delete this.opt["CHI_PAI"];
    },
};

dwc.YNMJ_Page = {
    roomType:"YNMJ",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_JHMJ");
        rootNode.setVisible(false);
        this.rootNode = rootNode;

        this.nodeFen = $.getNodeByName(rootNode,"ID_NODE_OPT_FEN");
        this.nodeFen.setVisible(false);

        this.nodeJU = $.getNodeByName(rootNode,"ID_NODE_OPT_JU");
        this.nodeJU.setVisible(false);

        this.optDaKunCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DAKUN");
        this.optDaKunCheckBox.addEventListener(function (sender,type) {
            that.OnDaKunCheckBox(sender,type);
        },this);
        //this.optDaKunLabel=$.getNodeByName(rootNode,"ID_LABEL_DAKUN_TEXT");

        this.optChangPaoCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_CHANGPAO");
        this.optChangPaoCheckBox.addEventListener(function (sender,type) {
            that.OnChangPaoCheckBox(sender,type);
        },this);
        //this.optChangPaoLabel=$.getNodeByName(rootNode,"ID_LABEL_CHANGPAO_TEXT");

        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");


        this.optDI36CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DI36");
        this.optDI36CheckBox.addEventListener(function (sender, type) {
            that.OnDI36CheckBox(sender,type);
        },this);
        //this.optQiZhuang36Text=$.getNodeByName(rootNode,"ID_LABEL_DI36_TEXT");

        this.optDI48CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DI48");
        this.optDI48CheckBox.addEventListener(function (sender, type) {
            that.OnDI48CheckBox(sender,type);
        },this);
        //this.optDI48Text=$.getNodeByName(rootNode,"ID_LABEL_DI48_TEXT");

        this.optFD40CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FD40");
        this.optFD40CheckBox.addEventListener(function (sender,type) {
            that.OnFD40CheckBox(sender,type);
        },this);
        //this.optFD40Label=$.getNodeByName(rootNode,"ID_LABEL_FD40_TEXT");

        this.optFD50CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FD50");
        this.optFD50CheckBox.addEventListener(function (sender,type) {
            that.OnFD50CheckBox(sender,type);
        },this);
        //this.optFD50Label=$.getNodeByName(rootNode,"ID_LABEL_FD50_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.OnDaKunCheckBox();
        this.On8juCheckBox();
        this.OnDI36CheckBox();
        this.OnFD40CheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.opt["8JU"])
        {
            minNumGem=1;
        }else  if(this.opt["16JU"])
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    //4局
    OnDaKunCheckBox: function (sender , CheckBoxType) {
        this.optDaKunCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);

        this.optChangPaoCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);

        this.nodeFen.setVisible(true);
        this.nodeJU.setVisible(false);
        this.opt["4JU"] = true;
        delete this.opt["8JU"];

    },
    //8局
    OnChangPaoCheckBox: function (sender , CheckBoxType) {
        this.optChangPaoCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(true);
        this.optDaKunCheckBox.setSelected(false);
        //this.opt8juLabel.setTextColor(cc.color.RED);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setTextColor(cc.color.WHITE);

        this.opt["8JU"] = true;
        delete this.opt["4JU"];
    },

    //飞小鸟
    OnFD40CheckBox: function (sender , CheckBoxType)
    {
        this.optFD40CheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.optFD50CheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);

        this.opt["XIAO_NIAO"] = true;
        delete this.opt["BAI_BAN"];

    },
    //飞白板
    OnFD50CheckBox: function (sender , CheckBoxType)
    {

        this.optFD50CheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.optFD40CheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);

        this.opt["BAI_BAN"] = true;
        delete this.opt["XIAO_NIAO"];

    },
    //4局
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setTextColor(cc.color.RED);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setTextColor(cc.color.WHITE);

        this.opt["4JU"] = true;
        delete this.opt["8JU"];
    },
    //8局
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setTextColor(cc.color.RED);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setTextColor(cc.color.WHITE);

        this.opt["16JU"] = true;
        delete this.opt["8JU"];
    },

    OnDI36CheckBox: function (sender , CheckBoxType) {
        this.optDI36CheckBox.setSelected(true);
        //this.optMoGuiText.setColor(cc.color.GREEN);
        this.optDI48CheckBox.setSelected(false);
        //this.optGuiX1Text.setColor(cc.color.GREEN);

        this.opt["CHI_PAI"] = true;
        delete this.opt["BU_CHI_PAI"];
    },
    OnDI48CheckBox: function (sender , CheckBoxType) {
        this.optDI36CheckBox.setSelected(false);
        //this.optMoGuiText.setColor(cc.color.GREEN);
        this.optDI48CheckBox.setSelected(true);
        //this.optGuiX1Text.setColor(cc.color.GREEN);

        this.opt["BU_CHI_PAI"] = true;
        delete this.opt["CHI_PAI"];
    },
};
dwc.CSMJ_Page = {
    roomType:"CSMJ",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_CSMJ");
        rootNode.setVisible(false);
        this.rootNode = rootNode;

        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");


        this.optDI36CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DI36");
        this.optDI36CheckBox.addEventListener(function (sender, type) {
            that.OnDI36CheckBox(sender,type);
        },this);
        this.optDI36Text=$.getNodeByName(rootNode,"ID_LABEL_DI36_TEXT");

        this.optDI48CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_DI48");
        this.optDI48CheckBox.addEventListener(function (sender, type) {
            that.OnDI48CheckBox(sender,type);
        },this);
        this.optDI48Text=$.getNodeByName(rootNode,"ID_LABEL_DI48_TEXT");
        

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On8juCheckBox();
        this.OnDI36CheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.opt["8JU"])
        {
            minNumGem=1;
        }else  if(this.opt["16JU"])
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setTextColor(cc.color.RED);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setTextColor(cc.color.WHITE);

        this.opt["8JU"] = true;
        delete this.opt["16JU"];
    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setTextColor(cc.color.RED);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setTextColor(cc.color.WHITE);

        this.opt["16JU"] = true;
        delete this.opt["8JU"];
    },

    OnDI36CheckBox: function (sender , CheckBoxType) {
        this.optDI36CheckBox.setSelected(true);
        //this.optMoGuiText.setColor(cc.color.GREEN);
        this.optDI48CheckBox.setSelected(false);
        //this.optGuiX1Text.setColor(cc.color.GREEN);

        this.opt["DI36"] = true;
        delete this.opt["DI48"];
    },
    OnDI48CheckBox: function (sender , CheckBoxType) {
        this.optDI36CheckBox.setSelected(false);
        //this.optMoGuiText.setColor(cc.color.GREEN);
        this.optDI48CheckBox.setSelected(true);
        //this.optGuiX1Text.setColor(cc.color.GREEN);

        this.opt["DI48"] = true;
        delete this.opt["DI36"];
    },
};
dwc.NBMJ_Page = {
    roomType:"NBMJ",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_NBMJ");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");


        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On8juCheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="8JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="16JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.jushu="16JU";
        this.opt["16JU"] = true;
        delete this.opt["8JU"];
        cc.log(this.opt);

    },

};

dwc.ZJH_Page = {
    roomType:"ZJH",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_ZJH");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");

        var optFD30CheckBox=this.optFD30CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FD30");
        optFD30CheckBox.addEventListener(function (sender,type) {
            that.OnFD30CheckBox(sender,type);
        },this);
        this.optFD30Text=$.getNodeByName(rootNode,"ID_LABEL_FD30_TEXT");

        var optFD50CheckBox=this.optFD50CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FD50");
        optFD50CheckBox.addEventListener(function (sender,type) {
            that.OnFD50CheckBox(sender,type);
        },this);
        this.optFD50Text=$.getNodeByName(rootNode,"ID_LABEL_FD50_TEXT");


        var optFD100CheckBox=this.optFD100CheckBox=$.getNodeByName(rootNode,"ID_BUTTON_FD100");
        optFD100CheckBox.addEventListener(function (sender,type) {
            that.OnFD100CheckBox(sender,type);
        },this);
        this.optFD100Text=$.getNodeByName(rootNode,"ID_LABEL_FD100_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On8juCheckBox();
        this.OnFD30CheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="8JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="16JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.jushu="16JU";
        this.opt["16JU"] = true;
        delete this.opt["8JU"];
        cc.log(this.opt);

    },
    OnFD30CheckBox: function (sender , CheckBoxType) {
        this.optFD30CheckBox.setSelected(true);
        //this.optFD30Text.setColor(cc.color.GREEN);
        this.optFD50CheckBox.setSelected(false);
        //this.optFD50Text.setColor(cc.color.WHITE);
        this.optFD100CheckBox.setSelected(false);
        //this.optFD100Text.setColor(cc.color.WHITE);
        this.opt8juLabel.setString("8局(房卡x1)");
        this.opt16juLabel.setString("16局(房卡x2)");

        this.opt["FD30"] = true;
        delete this.opt["FD10"];
        delete this.opt["FD50"];
        delete this.opt["FD100"];
        //this.renew_desc();
    },
    OnFD50CheckBox: function (sender , CheckBoxType) {
        this.optFD50CheckBox.setSelected(true);
        //this.optFD50Text.setColor(cc.color.GREEN);
        this.optFD30CheckBox.setSelected(false);
        //this.optFD30Text.setColor(cc.color.WHITE);
        this.optFD100CheckBox.setSelected(false);
        //this.optFD100Text.setColor(cc.color.WHITE);
        //this.optCostX2DescLabel.setString("提示：房卡消耗翻倍");

        this.opt8juLabel.setString("8局(房卡x2)");
        this.opt16juLabel.setString("16局(房卡x4)");

        this.opt["FD50"] = true;
        delete this.opt["FD10"];
        delete this.opt["FD30"];
        delete this.opt["FD100"];

        //this.renew_desc();
        //this.OnWinPayCheckBox(null,null);
    },

    OnFD100CheckBox: function (sender , CheckBoxType) {
        this.optFD100CheckBox.setSelected(true);
        //this.optFD100Text.setColor(cc.color.GREEN);
        this.optFD50CheckBox.setSelected(false);
        //this.optFD50Text.setColor(cc.color.WHITE);
        this.optFD30CheckBox.setSelected(false);
        //this.optFD30Text.setColor(cc.color.WHITE);
        //this.optCostX2DescLabel.setString("提示：房卡消耗翻倍");

        this.opt8juLabel.setString("8局(房卡x3)");
        this.opt16juLabel.setString("16局(房卡x6)");

        this.opt["FD100"] = true;
        delete this.opt["FD10"];
        delete this.opt["FD30"];
        delete this.opt["FD50"];

        //this.renew_desc();
        //this.OnWinPayCheckBox(null,null);
    },
};
dwc.NIUNIU_Page = {
    roomType:"NIUNIU",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_NIUNIU");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();

        });
        this.On8juCheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="8JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="16JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.jushu="16JU";
        this.opt["16JU"] = true;
        delete this.opt["8JU"];
        cc.log(this.opt);

    }
};
dwc.SG_Page = {
    roomType:"SG",
    setTarget : function(target)
    {
        this.target = target;
    },
    init : function(mainNode)
    {
        this.opt = {};
        var that = this;
        var rootNode = $.getNodeByName(mainNode,"ID_NODE_OPT_SG");
        rootNode.setVisible(false);
        this.rootNode = rootNode;
        this.opt8juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_8JU");
        this.opt8juCheckBox.addEventListener(function (sender,type) {
            that.On8juCheckBox(sender,type);
        },this);
        this.opt8juLabel=$.getNodeByName(rootNode,"ID_LABEL_8JU_TEXT");

        this.opt16juCheckBox=$.getNodeByName(rootNode,"ID_BUTTON_16JU");
        this.opt16juCheckBox.addEventListener(function (sender,type) {
            that.On16juCheckBox(sender,type);
        },this);
        this.opt16juLabel=$.getNodeByName(rootNode,"ID_LABEL_16JU_TEXT");

        var cjfjBtn=$.getNodeByName(rootNode,"ID_BUTTON_CJFJ");
        cjfjBtn.addClickEventListener(function () {
            that.OnCreateRoomBtnClick();
        });
        this.On8juCheckBox();
    },
    setVisible : function(bVisible)
    {
        this.rootNode.setVisible(bVisible);
    },
    OnCreateRoomBtnClick : function()
    {
        var that=this;
        if(dwc.Myself.GetMyRoom())
        {
            that.OnFanHuiRoom();
            return;
        }
        var minNumGem=1;

        if(this.jushu=="8JU")
        {
            minNumGem=1;
        }else  if(this.jushu=="16JU")
        {
            minNumGem=2;
        }

        //minNumGem=100;
        if(dwc.Myself.GetData().GetGem()>=minNumGem)
        {
            //that.ShowLoading(true);

            var keys = [];
            for(var key in this.opt)
            {
                keys.push(key);
            }
            dwc.DT_Data_Login.SendCreateRoom(that.roomType,keys.join(";"));
            //that.Close();
        }else {
            if(this.target)
                this.target.OnShowHint("房卡不足,请充值或联系代理");
        }
    },
    On8juCheckBox: function (sender , CheckBoxType) {
        this.opt8juCheckBox.setSelected(true);
        //this.opt8juLabel.setColor(cc.color.GREEN);
        this.opt16juCheckBox.setSelected(false);
        //this.opt16juLabel.setColor(cc.color.WHITE);
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

    },
    On16juCheckBox: function (sender , CheckBoxType) {
        this.opt16juCheckBox.setSelected(true);
        //this.opt16juLabel.setColor(cc.color.GREEN);
        this.opt8juCheckBox.setSelected(false);
        //this.opt8juLabel.setColor(cc.color.WHITE);
        this.jushu="16JU";
        this.opt["16JU"] = true;
        delete this.opt["8JU"];
        cc.log(this.opt);

    },
};
dwc.CreateRoomDialog=dwc.CommonAlertView.extend({
    roomType:"YNMJ",
    jushu:"8JU",

    ctor: function (target) {
        this._super();
        this.target = target;
        this.curPage = 0;
        this.initUI(target);
    },
    initUI: function (_msg) {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_createroom_json).node;

        this.addChild(mainNode);
        this.mainNode = mainNode;

        //提示
        this.hintBack=$.getNodeByName(mainNode,"ID_SPRITE_HINT_MSG");
        //this.hintBack.setVisible(false);
        this.hintLabel=$.getNodeByName(mainNode,"ID_LABEL_HINTLABEL");
        //this.OnShowHint("xxxxxxxxxxxxxxxxxxxxxxx");
        this.opt = {};
        this.jushu="8JU";
        this.opt["8JU"] = true;
        delete this.opt["16JU"];

        var btn_JiHu=this.btn_JiPingHu=$.getNodeByName(mainNode,"ID_BUTTON_JIPINGHU");
        btn_JiHu.addClickEventListener(function () {
            that.OnJiPingHuBtnClick();
        });
        var btn_TuiDaoHu=this.btn_TuiDaoHu=$.getNodeByName(mainNode,"ID_BUTTON_TUIDAOHU");
        btn_TuiDaoHu.addClickEventListener(function () {
            that.OnTuiDaoHuBtnClick();
        });

        var btn_GBMJ=this.btn_GBMJ=$.getNodeByName(mainNode,"ID_BUTTON_GBMJ");
        btn_GBMJ.addClickEventListener(function () {
            that.OnGBMJBtnClick();
        });
        var btn_XLCH=this.btn_XLCH=$.getNodeByName(mainNode,"ID_BUTTON_XLCH");
        btn_XLCH.addClickEventListener(function () {
            that.OnXLCHBtnClick();
        });
        var btn_JHMJ=this.btn_JHMJ=$.getNodeByName(mainNode,"ID_BUTTON_XLCH");
        btn_JHMJ.addClickEventListener(function () {
            that.OnJHMJBtnClick();
        });

        var btn_YNMJ=this.btn_YNMJ=$.getNodeByName(mainNode,"ID_BUTTON_JHMJ");
        btn_YNMJ.addClickEventListener(function () {
            that.OnYNMJBtnClick();
        });

        //var btn_CSMJ=this.btn_CSMJ=$.getNodeByName(mainNode,"ID_BUTTON_CSMJ");
        //btn_CSMJ.addClickEventListener(function () {
        //    that.OnCSMJBtnClick();
        //});
        //var btn_NBMJ=this.btn_NBMJ=$.getNodeByName(mainNode,"ID_BUTTON_NBMJ");
        //btn_NBMJ.addClickEventListener(function () {
        //    that.OnNBMJBtnClick();
        //});
        //var btn_ZJH=this.btn_ZJH=$.getNodeByName(mainNode,"ID_BUTTON_ZJH");
        //btn_ZJH.addClickEventListener(function () {
        //    that.OnZJHBtnClick();
        //});
        //var btn_NIUNIU=this.btn_NIUNIU=$.getNodeByName(mainNode,"ID_BUTTON_NIUNIU");
        //btn_NIUNIU.addClickEventListener(function () {
        //    that.OnNIUNIUBtnClick();
        //});
        //var btn_SG=this.btn_SG=$.getNodeByName(mainNode,"ID_BUTTON_SG");
        //btn_SG.addClickEventListener(function () {
        //    that.OnSGBtnClick();
        //});
        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });

        //this.initDiFangPage();
        this.initTuiDaoHuPage();
        this.initJiPingHuPage();
        this.initGuoBiaoPage();
        this.initXLCHPage();

        this.initJHMJPage();
        this.initYNMJPage();
        this.initCSMJPage();
        this.initZJHPage();
        this.initNIUNIUPage();
        this.initSGPage();
        this.initNBMJPage();

        //dwc.TuiDaoHu_Page.setVisible(true);
        //dwc.JIPINGHU_Page.setVisible(true);

        //this.OnDFWFBtnClick();

        //this.btn_JiPingHu.setVisible(false);
        //this.btn_TuiDaoHu.setVisible(false);

        //this.On8juCheckBox();
        //this.OnGuiPaiCheckBox();


        this.mainButtons = [this.btn_JHMJ, this.btn_YNMJ];
        this.mainPages = [dwc.JHMJ_Page,dwc.YNMJ_Page];

        this.OnYNMJBtnClick();
    },
    initDiFangPage : function(){
        this.initTuiDaoHuPage();
    },
    initTuiDaoHuPage : function(){
        var that = this;

        dwc.TuiDaoHu_Page.init(this.mainNode);
        dwc.TuiDaoHu_Page.setTarget(this);
    },

    initJiPingHuPage : function(){
        var that = this;

        dwc.JIPINGHU_Page.init(this.mainNode);
        dwc.JIPINGHU_Page.setTarget(this);
    },
    initGuoBiaoPage : function(){
        var that = this;

        dwc.GBMJ_Page.init(this.mainNode);
        dwc.GBMJ_Page.setTarget(this);
    },
    initXLCHPage : function(){
        var that = this;

        dwc.XLCH_Page.init(this.mainNode);
        dwc.XLCH_Page.setTarget(this);
    },
    initJHMJPage : function(){
        var that = this;

        dwc.JHMJ_Page.init(this.mainNode);
        dwc.JHMJ_Page.setTarget(this);
    },    

    initYNMJPage : function(){
        var that = this;

        dwc.YNMJ_Page.init(this.mainNode);
        dwc.YNMJ_Page.setTarget(this);
    },
    initCSMJPage : function(){
        var that = this;

        dwc.CSMJ_Page.init(this.mainNode);
        dwc.CSMJ_Page.setTarget(this);
    },
    initNBMJPage : function(){
        var that = this;

        dwc.NBMJ_Page.init(this.mainNode);
        dwc.NBMJ_Page.setTarget(this);
    },
    initZJHPage : function(){
        var that = this;

        dwc.ZJH_Page.init(this.mainNode);
        dwc.ZJH_Page.setTarget(this);
    },
    initNIUNIUPage : function(){
        var that = this;

        dwc.NIUNIU_Page.init(this.mainNode);
        dwc.NIUNIU_Page.setTarget(this);
    },
    initSGPage : function(){
        var that = this;

        dwc.SG_Page.init(this.mainNode);
        dwc.SG_Page.setTarget(this);
    },
    OnShowHint: function (content) {
        var that=this;
        this.hintLabel.setString(content);
        this.hintBack.stopAllActions();
        this.hintLabel.stopAllActions();
        this.hintBack.setVisible(true);
        this.hintLabel.setPosition(600,23);
        this.hintBack.runAction(cc.sequence(cc.delayTime(1.6),cc.callFunc(function () {
            that.hintBack.setVisible(false);
            that.hintLabel.setPosition(600,23);
        },this)))
        this.hintLabel.runAction(cc.moveTo(0.2,cc.p(600,75)));
    },
    OnJiPingHuBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_JiPingHu)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.JIPINGHU_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },
    OnTuiDaoHuBtnClick: function () {

        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_TuiDaoHu)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.TuiDaoHu_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },

    OnGBMJBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_GBMJ)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.GBMJ_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },
    OnXLCHBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_XLCH)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.XLCH_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },

    OnJHMJBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_JHMJ)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.JHMJ_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },


    OnYNMJBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_YNMJ)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.YNMJ_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },


    OnCSMJBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_CSMJ)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.CSMJ_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },
    OnZJHBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_ZJH)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.ZJH_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },
    OnNIUNIUBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_NIUNIU)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.NIUNIU_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },
    OnSGBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_SG)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.SG_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },
    OnNBMJBtnClick: function () {
        for(var i=0;i<this.mainButtons.length;i++)
        {
            var button = this.mainButtons[i];
            var page = this.mainPages[i];
            if(button == this.btn_NBMJ)
            {
                button.setBright(false);
                button.setEnabled(false);
            }else{
                button.setBright(true);
                button.setEnabled(true);
            }
            if(page == dwc.NBMJ_Page)
            {
                page.setVisible(true);
            }else{
                page.setVisible(false);
            }
        }
    },
});

dwc.JoinRoomDialog=dwc.CommonAlertView.extend({
    mInputRoomID : "",
    ctor: function (target) {
        this._super();
        this.target = target;
        this.mInputRoomID = "";
        this.initUI(target);
    },
    initUI: function (target) {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_joinroom_json).node;
        this.addChild(mainNode);

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });

        this.vecRoomIDLabel = [];
        for(var i=0;i<6;i++)
        {
            var numberText = $.getNodeByName(mainNode,"ID_TEXT_NUM"+i);
            this.vecRoomIDLabel[i] = numberText;
        }


        $.getNodeByName(mainNode,"ID_BUTTON_N0").addClickEventListener(function () {            that.OnNumberKeyboard(0);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N1").addClickEventListener(function () {            that.OnNumberKeyboard(1);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N2").addClickEventListener(function () {            that.OnNumberKeyboard(2);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N3").addClickEventListener(function () {            that.OnNumberKeyboard(3);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N4").addClickEventListener(function () {            that.OnNumberKeyboard(4);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N5").addClickEventListener(function () {            that.OnNumberKeyboard(5);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N6").addClickEventListener(function () {            that.OnNumberKeyboard(6);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N7").addClickEventListener(function () {            that.OnNumberKeyboard(7);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N8").addClickEventListener(function () {            that.OnNumberKeyboard(8);        });
        $.getNodeByName(mainNode,"ID_BUTTON_N9").addClickEventListener(function () {            that.OnNumberKeyboard(9);        });

        var numberResetBtn = $.getNodeByName(mainNode,"ID_BUTTON_NRESET");
        numberResetBtn.addClickEventListener(function () {
            that.OnNumberKeyboard(10);
        });
        var numberDelBtn = $.getNodeByName(mainNode,"ID_BUTTON_NDEL");
        numberDelBtn.addClickEventListener(function () {
            that.OnNumberKeyboard(11);
        });

        this.renew_ui();
    },
    OnNumberKeyboard : function(index)
    {

        if(index >= 0 && index < 10)
        {
            if(this.mInputRoomID.length < 6) {
                this.mInputRoomID = this.mInputRoomID + index.toString();
            }
            if(this.mInputRoomID.length == 6)
            {
                try
                {
                    var room_id = parseInt(this.mInputRoomID);
                    dwc.DT_Data_Login.SendJoinRoom(room_id,"");
                }catch (e)
                {
                    cc.log(e.name + ":" + e.message);
                }
            }
        }
        if(index == 10)
        {
            this.mInputRoomID = "";
        }
        if(index == 11)
        {
            if(this.mInputRoomID.length > 0)
            {
                this.mInputRoomID=this.mInputRoomID.substr(0,this.mInputRoomID.length-1);
            }

        }
        cc.audioEngine.playEffect("res/audio/pop.wav",false);
        this.renew_ui();

    },
    renew_ui : function()
    {
        for(var i=0;i<this.vecRoomIDLabel.length;i++) {
            this.vecRoomIDLabel[i].setString("");
        }
        for(var i=0;i<this.mInputRoomID.length;i++)
        {
            if(i<6)
            {
                this.vecRoomIDLabel[i].setString(this.mInputRoomID[i]);
            }
        }
    }
});

dwc.SettingDialog=dwc.CommonAlertView.extend({
    ctor: function (target) {
        this._super();
        this.target = target;
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_setting_json).node;
        this.addChild(mainNode);

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });

        var loginOut=$.getNodeByName(mainNode,"ID_BUTTON_LOGINOUT");
        loginOut.addClickEventListener(function () {
            cc.sys.localStorage.setItem("QQ_DATA","");
            cc.sys.localStorage.setItem("WX_DATA","");
            cc.sys.localStorage.setItem("device","");
            cc.sys.localStorage.setItem("YKUID","");
            cc.sys.localStorage.setItem("QQUID","");
            cc.sys.localStorage.setItem("WXUID","");
            cc.director.runScene(new dwc.LoginScene());
        });


        this.effectBtn=$.getNodeByName(mainNode,"ID_CHECKBOX_EFFECT");
        this.effectBtn.addEventListener(function (sender,type) {
            if(!that.effectBtn.isSelected())
            {
                that.effectBtn.setSelected(false);
                cc.audioEngine.setEffectsVolume(0.0);
            }else{
                that.effectBtn.setSelected(true);
                cc.audioEngine.setEffectsVolume(0.8);
            }
        });

        this.musicBtn=$.getNodeByName(mainNode,"ID_CHECKBOX_MUSIC");
        this.musicBtn.addEventListener(function (sender,type) {
            if(!that.musicBtn.isSelected())
            {
                that.musicBtn.setSelected(false);
                cc.audioEngine.setMusicVolume(0.0);
            }else{
                that.musicBtn.setSelected(true);
                cc.audioEngine.setMusicVolume(0.8);
            }
        });
    },

});

dwc.HelpDialog=dwc.CommonAlertView.extend({
    ctor: function (target) {
        this._super();
        this.target = target;
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_help_json).node;
        this.addChild(mainNode);

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });
    },
});
dwc.TuiGuangDialog=dwc.CommonAlertView.extend({
    ctor: function (target) {
        this._super();
        this.target = target;
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_tuiguang_json).node;
        this.addChild(mainNode);

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });
        that.agentLabel=$.getNodeByName(mainNode,"ID_TEXT_AGENTID");
        var agent_id = dwc.Myself.GetData().GetAgent();
        if(agent_id)
        {
            that.agentLabel.setString("" + agent_id);
            that.agentLabel.setEnabled(false);
        }
        var bindBtn=$.getNodeByName(mainNode,"ID_BUTTON_BINDAGENT");
        bindBtn.addClickEventListener(function () {
            var agent = that.agentLabel.getString();
            var pattern=new RegExp("\\D");
            if(agent && agent.length > 0)
            {
                if(pattern.test(agent))
                {
                    if($.runningScene)
                    {
                        var alert = new dwc.PopupAlert("请输入数字推荐码");
                        $.runningScene.addChild(alert);
                        alert.Show();
                    }
                }else{
                    var int_agent = parseInt(agent);
                    if(int_agent == dwc.Myself.GetData().GetUid()) {
                        var alert = new dwc.PopupAlert("不能绑定自己的用户UID");
                        $.runningScene.addChild(alert);
                        alert.Show();
                    }else{
                        dwc.DT_Data_Login.sendBindAgent(parseInt(agent));
                        dwc.Myself.GetData().SetAgent(parseInt(agent));
                    }
                }
            }else{
                if($.runningScene)
                {
                    var alert = new dwc.PopupAlert("请输入数字推荐码");
                    $.runningScene.addChild(alert);
                    alert.Show();
                }
            }

        });
    },
});
dwc.MsgDialog=dwc.CommonAlertView.extend({
    ctor: function (target) {
        this._super();
        this.target = target;
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_msg_json).node;
        this.addChild(mainNode);
        this.bgLayout=$.getNodeByName(mainNode,"ID_LAYOUT_BG");
        this.bgLayout.addClickEventListener(function () {
            that.Close();
        });
        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });

        if($.last_gonggao_text)
        {
            var textLabel=$.getNodeByName(mainNode,"Text_1_0");

            textLabel.setString($.last_gonggao_text);
        }
    },
});
dwc.ZhanJiDialog=dwc.CommonAlertView.extend({
    ctor: function (target) {
        this._super();
        this.target = target;
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_zhanji_json).node;
        this.addChild(mainNode);
        this.noMsgLabel=$.getNodeByName(mainNode,"ID_LABLE_NOMSG");

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });
        dwc.GX_NetWorkManager.SendMessage("http://zjmj.cjpoker.com/app/battle_api.php?a=ninedt_battle_userlog&uid=" + dwc.Myself.GetData().GetUid(),
            function (_msg) {
                that.message=JSON.parse(_msg);
                that.initTable(mainNode);
            });
    },
    initTable: function (mainNode)
    {
        if(this.message && this.message.data && this.message.data.length > 0)
        {
            this.noMsgLabel.setVisible(false);
        }
        this.tableBack=$.getNodeByName(mainNode,"ID_LAYOUT_TABLEBG");

        this.tableView=new cc.TableView(this,cc.size(1200,620));
        this.tableView.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL);
        this.tableView.setDelegate(this);
        this.tableView.setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN);
        this.tableBack.addChild(this.tableView);
        this.tableView.reloadData();
    },
    tableCellTouched:function (table, cell) {

        /*
        cc.log("cell touched at index: " + cell.getIdx());
        var index=cell.getIdx()+1;

        var detail=new dwc.DT_ZhanJiDetail();
        this.addChild(detail);
        detail.Show();
        */
    },
    tableCellSizeForIndex:function(table, idx){
        return cc.size(1200,180);
    },
    tableCellAtIndex:function (table, idx) {
        var cell=table.dequeueCell();
        if (!cell){
            cell=new dwc.ZhanJiCell(idx,this.message.data);
        }else {
            cell.refresh(idx,this.message.data);
        }
        return cell;
    },
    numberOfCellsInTableView:function (table) {

        return this.message.data.length;
    },
});
//战绩cell
dwc.ZhanJiCell=cc.TableViewCell.extend({
    number:null,
    background:null,
    ctor:function(idx,data){
        var that = this;
        this._super();
        this.width=1200;
        this.height=160;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_zhanjiDetail_cell_json).node;
        this.addChild(mainNode);

        this.battle_video = data[idx].battle_video;
        this.indexLabel=$.getNodeByName(mainNode,"ID_LABEL_JS");
        this.roomIDLabel=$.getNodeByName(mainNode,"ID_LABEL_FJH");
        this.timeLabel=$.getNodeByName(mainNode,"ID_LABEL_TIME");

        this.replayBtn=$.getNodeByName(mainNode,"ID_BUTTON_REPLAY");
        this.replayBtn.addClickEventListener(function () {
            if($.runningScene)
            {
                var alert = new dwc.ReplayDialog($.runningScene,that.battle_video);
                $.runningScene.addChild(alert);
                alert.Show();
            }
        });
        this.userInfoList=[];
        for(var i=0;i<5;i++){
            var name=$.getNodeByName(mainNode,"ID_LABEL_NAME"+i);
            var score=$.getNodeByName(mainNode,"ID_LABEL_SCORE"+i);
            var userInfo={};
            userInfo.name=name;
            userInfo.score=score;
            this.userInfoList[i]=userInfo;
        }
        var battle_video = data[idx].battle_video;
        if(battle_video && battle_video.length > 100) {
            this.replayBtn.setVisible(true);
        }else{
            this.replayBtn.setVisible(false);
        }
        this.refresh(idx,data);

    },
    refresh:function(idx,data) {
        var battle_video = data[idx].battle_video;
        this.battle_video = battle_video;
        if(battle_video && battle_video.length > 100) {
            this.replayBtn.setVisible(true);
        }else{
            this.replayBtn.setVisible(false);
        }
        this.indexLabel.setString(data[idx].battle_id);
        this.roomIDLabel.setString(data[idx].room_id);
        this.timeLabel.setString(data[idx].created);

        for(var i=0;i<5;i++){
            var userInfo=this.userInfoList[i];
            userInfo.name.setString(eval("data[idx].nickname"+i));
            userInfo.score.setString(eval("data[idx].score"+i));
        }
    }
});


dwc.ReplayDialog=dwc.CommonAlertView.extend({
    ctor: function (target,battle_video) {
        this._super();
        this.target = target;
        this.battle_video = JSON.parse(battle_video);
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_replay_json).node;
        this.addChild(mainNode);

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });

        that.initTable(mainNode);
    },
    initTable: function (mainNode)
    {
        this.tableBack=$.getNodeByName(mainNode,"ID_LAYOUT_TABLEBG");

        this.tableView=new cc.TableView(this,cc.size(1060,620));
        this.tableView.setDirection(cc.SCROLLVIEW_DIRECTION_VERTICAL);
        this.tableView.setDelegate(this);
        this.tableView.setVerticalFillOrder(cc.TABLEVIEW_FILL_TOPDOWN);
        this.tableBack.addChild(this.tableView);
        this.tableView.reloadData();
    },
    tableCellTouched:function (table, cell) {

        /*
         cc.log("cell touched at index: " + cell.getIdx());
         var index=cell.getIdx()+1;

         var detail=new dwc.DT_ZhanJiDetail();
         this.addChild(detail);
         detail.Show();
         */
    },
    tableCellSizeForIndex:function(table, idx){
        return cc.size(1000,180);
    },
    tableCellAtIndex:function (table, idx) {
        var cell=table.dequeueCell();
        if (!cell){
            cell=new dwc.ReplayCell(idx,this.battle_video);
        }else {
            cell.refresh(idx,this.battle_video);
        }
        return cell;
    },
    numberOfCellsInTableView:function (table) {
        if(this.battle_video.length > 0)
        {
            return this.battle_video.length-1;
        }
        return 0;
    },
});
//战绩cell
dwc.ReplayCell=cc.TableViewCell.extend({
    number:null,
    background:null,
    ctor:function(idx,data){
        this._super();
        this.width=1000;
        this.height=160;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_replay_cell_json).node;
        this.addChild(mainNode);

        var that = this;
        this.roundLabel=$.getNodeByName(mainNode,"ID_LABEL_ROUND");
        this.createdLabel=$.getNodeByName(mainNode,"ID_LABEL_CREATED");
        this.replayButton=$.getNodeByName(mainNode,"ID_BUTTON_REPLAY");
        this.replayButton.addClickEventListener(function () {
            that.OnReplay();
        });

        if(data.length > idx)
        {
            this.replayData = data[idx+1];

            this.roundLabel.setString("第" + this.replayData.round + "局");
            this.createdLabel.setString(this.replayData.created);
        }

    },
    OnReplay : function() {
        var that = this;
        if(this.replayData)
        {
            var playback_path = this.replayData.path;

            dwc.GX_NetWorkManager.SendMessage("http://upload.cjpoker.com/" + playback_path,
                function (_msg) {
                    that.replay(_msg);
                });
        }
    },
    replay : function(_msg)
    {
        try
        {
            var jsonMsg = JSON.parse(_msg);
            var header = jsonMsg[0];
            if(header.room_type == "JHMJ")
            {
                if($.runningScene)
                {
                    var alert = new jhmj.mj_playback(_msg);
                    $.runningScene.addChild(alert);
                    alert.Show();
                }
                //cc.director.runScene(new jhmj.mj_playback());
                //return;
            }
        }catch (e)
        {
            cc.log(e.name + ":" + e.message);
        }

    },
    refresh:function(idx,data) {
        if(data.length > idx) {
            this.replayData = data[idx + 1];
        }
        if (this.replayData) {
            this.roundLabel.setString("第" + this.replayData.round + "局");
            this.createdLabel.setString(this.replayData.created);
        }
    }
});
dwc.ShareDialog=dwc.CommonAlertView.extend({
    ctor: function (target,_param) {
        this._super();
        this.target = target;

        this.param = _param;

        this.initUI(target);
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_share_json).node;
        this.addChild(mainNode);

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });

        var wechatBtn=$.getNodeByName(mainNode,"ID_BUTTON_WECHAT");
        wechatBtn.addClickEventListener(function () {
            that.OnClickWeChat();
        });

        var timelineBtn=$.getNodeByName(mainNode,"ID_BUTTON_TIMELINE");
        timelineBtn.addClickEventListener(function () {
            that.OnClickTimeLinet();
        });
    },
    OnClickWeChat : function()
    {
        try
        {
            var obj = {};
            var bundle = $.getBundleID();

            if(!this.param)
            {
                var iconUrl="http://img.cjpoker.com/csmj.png";
                var appUrl="http://a.app.qq.com/o/simple.jsp?pkgname=com.cjpoker.zujumj";
                var title="云南小鸡麻将欢迎您";

                appUrl= "http://fir.im/ynxj";
                var text = "朋友们正在等你 赶紧加入吧！ 推荐人：" + dwc.Myself.GetData().GetNickName();
                obj["title"] = title;
                obj["text"] = text;
                obj["imageurl"] = iconUrl;
                obj["url"] = appUrl;
                try {
                    if (cc.sys.os == cc.sys.OS_ANDROID) {
                        jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "ShareToWeChat", "(Ljava/lang/String;)V", JSON.stringify(obj));
                    } else if (cc.sys.os == cc.sys.OS_IOS) {
                        jsb.reflection.callStaticMethod("RootViewController","OnSavePicWithName:shareType:shareContent:title:appUrl:text:iconUrl:","","wechat","auto",title,appUrl,text,iconUrl);
                    }
                }catch (e)
                {
                    cc.log(e.name + ":" + e.message);
                }

            }else{
                if (cc.sys.os == cc.sys.OS_ANDROID) {
                    //jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "ShareToWeChat", "(Ljava/lang/String;)V", JSON.stringify(this.param));
                } else if (cc.sys.os == cc.sys.OS_IOS) {
                    //jsb.reflection.callStaticMethod("RootViewController", "ShareToWeChat:param", JSON.stringify(this.param));
                }
            }
        }catch (e)
        {
            cc.log(e.name + ":" + e.message);
        }
    },
    OnClickTimeLinet : function()
    {
        try
        {
            var obj = {};
            var bundle = $.getBundleID();
            var iconUrl="http://img.cjpoker.com/csmj.png";
            var appUrl="http://a.app.qq.com/o/simple.jsp?pkgname=com.cjpoker.zujumj";
            var title="财神麻将欢迎您";
            var text = "朋友们正在等你 赶紧加入吧！ 推荐人：" + dwc.Myself.GetData().GetNickName();
	        appUrl= "http://zjmj.cjpoker.com/app/index.html";
	    
            var text = title;
            obj["title"] = title;
            obj["text"] = text;
            obj["imageurl"] = iconUrl;
            obj["url"] = appUrl;
            if(!this.param)
            {
                try {
                    if (cc.sys.os == cc.sys.OS_ANDROID) {
                        jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "ShareToTimeLine", "(Ljava/lang/String;)V", JSON.stringify(obj));
                    } else if (cc.sys.os == cc.sys.OS_IOS) {
                        jsb.reflection.callStaticMethod("RootViewController","OnSavePicWithName:shareType:shareContent:title:appUrl:text:iconUrl:","","pyq","auto",title,appUrl,text,iconUrl);
                    }
                }catch (e)
                {
                    cc.log(e.name + ":" + e.message);
                }
            }else {
                if (cc.sys.os == cc.sys.OS_ANDROID) {
                    //jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "ShareToTimeLine", "(Ljava/lang/String;)V", JSON.stringify(this.param));
                } else if (cc.sys.os == cc.sys.OS_IOS) {
                    //jsb.reflection.callStaticMethod("RootViewController", "ShareToTimeLine:param", JSON.stringify(this.param));
                }
            }
        }catch (e)
        {
            cc.log(e.name + ":" + e.message);
        }
    },
});

dwc.DaiLiDialog=dwc.CommonAlertView.extend({
    ctor: function (target) {
        this._super();
        this.target = target;
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_daili_json).node;
        this.addChild(mainNode);

        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {
            that.Close();
        });
    },
});

dwc.BaoMingDialog=dwc.CommonAlertView.extend({
    ctor: function (target) {
        this._super();
        this.target = target;
        this.initUI();
    },
    initUI: function () {
        var that = this;
        var mainNode = ccs.load(dwc.g_arrGCRes.dt_baoming_json).node;
        this.addChild(mainNode);

        var submitBtn=$.getNodeByName(mainNode,"ID_BUTTON_SUBMIT");
        submitBtn.addClickEventListener(function () {
            that.OnSubMit();
        });

        this.wechatText =$.getNodeByName(mainNode,"ID_TEXT_WECHAT");
        this.telText =$.getNodeByName(mainNode,"ID_TEXT_TEL");

        this.closeBtn =$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        this.closeBtn.addClickEventListener(function () {
            that.Close();
        });
    },

    OnSubMit : function()
    {
        var wechat = this.wechatText.getString();
        var tel = this.telText.getString();

        if(wechat.length > 3 && wechat.length < 60 && tel.length >= 6 && tel.length < 60)
        {
            var url = "http://zjmj.cjpoker.com/app/baoming.php?area=jinhua&wechat=" + wechat + "&tel=" + tel;
            dwc.GX_NetWorkManager.SendMessage(url,
                function (_msg) {
                    try
                    {
                        if($.runningScene)
                        {
                            var alert = new dwc.PopupAlert("报名成功，请等待我们的联络");
                            $.runningScene.addChild(alert);
                            alert.Show();
                        }
                    }catch (e)
                    {
                        cc.log(e.name + ":" + e.message);

                        if($.runningScene)
                        {
                            var alert = new dwc.PopupAlert("服务器内部错误，请联系客服咨询");
                            $.runningScene.addChild(alert);
                            alert.Show();
                        }
                    }
                });
        }else{
            if($.runningScene)
            {
                var alert = new dwc.PopupAlert("请输入正确的参数");
                $.runningScene.addChild(alert);
                alert.Show();
            }
        }
    },
});
//购买房卡商城///////////////////////////////////////////////////////////////////////////////////////////

dwc.DT_Shop=dwc.CommonAlertView.extend({
    ctor: function () {
        this._super();
        var self=this;
        var mainNode=ccs.load(dwc.g_arrGCRes.dt_shop_josn).node;
        this.addChild(mainNode);
        this.initUI(mainNode);

        cc.eventManager.addListener({
            event    : cc.EventListener.CUSTOM,
            eventName: "CHANGE_PLAYER_INFO",
            callback : function(event){
                self.refreshData();
            }
        }, this);

        this.initUI(mainNode);
    },
    refreshData: function () {
        this.gemLabel.setString(dwc.Myself.GetData().GetGem());
    },
    initUI: function (mainNode) {
        var self = this;var that = this;

        var gemLabel=self.gemLabel=$.getNodeByName(mainNode,"ID_LABEL_MYGEM");
        gemLabel.setString(dwc.Myself.GetData().GetGem());
        var closeBtn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSE");
        closeBtn.addClickEventListener(function () {self.Close();});
        for(var i=0;i<6;i++){
            var payBtn=$.getNodeByName(mainNode,"ID_BUTTON_PAYBTN"+i);
            payBtn.tag=i;
            payBtn.addClickEventListener(function (sender) {self.OnPayGemBtnClick(sender);});
        }
        //self.initPayWay(mainNode);

        that.agentLabel=$.getNodeByName(mainNode,"ID_TEXT_AGENTID");
        var agent_id = dwc.Myself.GetData().GetAgent();
        if(agent_id)
        {
            that.agentLabel.setString("" + agent_id);
            that.agentLabel.setEnabled(false);
        }
        var bindBtn=$.getNodeByName(mainNode,"ID_BUTTON_BINDAGENT");
        bindBtn.addClickEventListener(function () {
            var agent = that.agentLabel.getString();
            var pattern=new RegExp("\\D");
            if(agent && agent.length > 0)
            {
                if(pattern.test(agent))
                {
                    if($.runningScene)
                    {
                        var alert = new dwc.PopupAlert("请输入数字推荐码");
                        $.runningScene.addChild(alert);
                        alert.Show();
                    }
                }else{
                    var int_agent = parseInt(agent);
                    if(int_agent == dwc.Myself.GetData().GetUid()) {
                        var alert = new dwc.PopupAlert("不能绑定自己的用户UID");
                        $.runningScene.addChild(alert);
                        alert.Show();
                    }else{
                        dwc.DT_Data_Login.sendBindAgent(parseInt(agent));
                    }
                }

            }else{
                if($.runningScene)
                {
                    var alert = new dwc.PopupAlert("请输入数字推荐码");
                    $.runningScene.addChild(alert);
                    alert.Show();
                }
            }
        });

        this.paywayLayout=$.getNodeByName(mainNode,"ID_LAYOUT_PAYWAY");
        this.paywayLayout.setVisible(false);

        var closePaywayBtn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY_CLOSE");
        closePaywayBtn.addClickEventListener(function (sender) {self.paywayLayout.setVisible(false);});

        var payway1Btn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY1");
        payway1Btn.addClickEventListener(function (sender) {self.OnPayWayBtnClick(1);});

        var payway2Btn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY2");
        payway2Btn.addClickEventListener(function (sender) {self.OnPayWayBtnClick(2);});

        var payway3Btn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY3");
        payway3Btn.addClickEventListener(function (sender) {self.OnPayWayBtnClick(3);});

        this.paywayLayout=$.getNodeByName(mainNode,"ID_LAYOUT_PAYWAY");
        this.paywayLayout.setVisible(false);

        var closePaywayBtn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY_CLOSE");
        closePaywayBtn.addClickEventListener(function (sender) {self.paywayLayout.setVisible(false);});

        var payway1Btn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY1");
        payway1Btn.addClickEventListener(function (sender) {self.OnPayWayBtnClick(1);});

        var payway2Btn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY2");
        payway2Btn.addClickEventListener(function (sender) {self.OnPayWayBtnClick(2);});

        var payway3Btn=$.getNodeByName(mainNode,"ID_BUTTON_PAYWAY3");
        payway3Btn.addClickEventListener(function (sender) {self.OnPayWayBtnClick(3);});

        that.agentLabel=$.getNodeByName(mainNode,"ID_TEXT_AGENTID");
        var agent_id = dwc.Myself.GetData().GetAgent();
        if(agent_id)
        {
            that.agentLabel.setString("" + agent_id);
            that.agentLabel.setEnabled(false);
        }
        var bindBtn=$.getNodeByName(mainNode,"ID_BUTTON_BINDAGENT");
        bindBtn.addClickEventListener(function () {
            var agent = that.agentLabel.getString();
            var pattern=new RegExp("\\D");
            if(agent && agent.length > 0)
            {
                if(pattern.test(agent))
                {
                    if($.runningScene)
                    {
                        var alert = new dwc.PopupAlert("请输入数字推荐码");
                        $.runningScene.addChild(alert);
                        alert.Show();
                    }
                }else{
                    var int_agent = parseInt(agent);
                    if(int_agent == dwc.Myself.GetData().GetUid()) {
                        var alert = new dwc.PopupAlert("不能绑定自己的用户UID");
                        $.runningScene.addChild(alert);
                        alert.Show();
                    }else{
                        dwc.DT_Data_Login.sendBindAgent(parseInt(agent));
                        that.txyqmBack.setVisible(false);
                        //dwc.Myself.GetData().SetAgent(parseInt(agent));
                    }
                }
            }else{
                if($.runningScene)
                {
                    var alert = new dwc.PopupAlert("请输入数字推荐码");
                    $.runningScene.addChild(alert);
                    alert.Show();
                }
            }
        }.bind(this));

        //提示
        this.hintBack=$.getNodeByName(mainNode,"ID_SPRITE_HINT_MSG");
        this.hintBack.setVisible(false);
        this.hintLabel=$.getNodeByName(mainNode,"ID_LABEL_HINTLABEL");

        var YQM_btn=$.getNodeByName(mainNode,"ID_BUTTON_YQMBTN");
        YQM_btn.addClickEventListener(function () {
            this.txyqmBack.setVisible(true);
        }.bind(this));

        //是否弹出填写邀请码
        this.txyqmBack=$.getNodeByName(mainNode,"ID_LAYOUT_TXYQMBG");
        this.txyqmBack.setVisible(false);
        var agent_id = dwc.Myself.GetData().GetAgent();
        if(agent_id)
        {
            this.txyqmBack.setVisible(false);
        }else
        {
            this.txyqmBack.setVisible(true);
        }
        var CLOSE_YQM_btn=$.getNodeByName(mainNode,"ID_BUTTON_CLOSETXYQM");
        CLOSE_YQM_btn.addClickEventListener(function () {
            this.txyqmBack.setVisible(false);
        }.bind(this));
    },
    initPayWay: function (mainNode) {
        var self=this;
        var payWayBack=self.payWayBack=$.getNodeByName(mainNode,"ID_LAYOUT_PAYWAYBACK");
        payWayBack.setVisible(false);
        payWayBack.addClickEventListener(function (sender) { self.payWayBack.setVisible(false);});


        var alipayBtn=$.getNodeByName(mainNode,"ID_BUTTON_ZFB");
        alipayBtn.tag=1;
        alipayBtn.addClickEventListener(function (sender) { self.OnSurePayWayClick(sender);});
        var wxpayBtn=$.getNodeByName(mainNode,"ID_BUTTON_WX");
        wxpayBtn.tag=2;
        wxpayBtn.addClickEventListener(function (sender) { self.OnSurePayWayClick(sender);});
    },
    OnPayGemBtnClick: function (sender) {
        var that = this;

        this.index=sender.tag;
        var agent_id = dwc.Myself.GetData().GetAgent();
        var vecTmp = [];

        var ret = vecTmp.indexOf(this.index);
        if(!agent_id && ret  >= 0)
        {
            this.txyqmBack.setVisible(true);
            this.OnShowHint("需绑定代理");
            return;
        }

        var payMethod = $.getPayMethod();
        var curShopGoodsList = dwc.ShopGoodList;
        var goodDetail = curShopGoodsList[this.index];


        var payment = goodDetail;
        var id = payment["id"];
        var item_id = payment.item_id;
        var price  = payment.price;

        this.payment = payment;
        this.paywayLayout.setVisible(true);
        var bH5Pay = "true";
        if(bH5Pay != "false")
        {
            //this.goto99EPay(payment);
            this.paywayLayout.setVisible(true);
        }else{

            //return;

            cc.audioEngine.playEffect("res/audio/pop.wav",false);

            $.setPayMethod("WeChat");
            this.goto_app_pingxx(payment,"WeChat");
        }
    },
    OnPayWayBtnClick: function (index) {
        var that = this;
        if(this.payment)
        {
            if(index == 1)
            {
                this.goto_h5_weixin_99EPay(this.payment);
            }
            if(index == 2)
            {
                this.goto_h5_weixin_szhuyu(this.payment);
            }
            if(index == 3)
            {
                this.goto_h5_alipay_szhuyu(this.payment);
            }
        }
    },
    goto_h5_weixin_99EPay : function(payment)
    {
        var id = payment["id"];
        var item_id = payment.item_id;
        var price  = payment.price;

        var bundle = $.getBundleID();
        $.uid = dwc.Myself.GetData().GetUid();
        var order_no = $.uid + "_" + Date.now();
        var s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=ios";
        if (cc.sys.os == cc.sys.OS_ANDROID) {
            s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=android";
        }
        if (cc.sys.os == cc.sys.OS_IOS) {
            s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=ios";
        }
        //http://api.99epay.net/h5Pay/order/mkH5Order.htm
        //http://api.99epay.net/mctrpc/order/mkReceiptOrder.htm
        //http://zjmj.cjpoker.com/app/h5pay.php",
        var url = "http://zjmj.cjpoker.com/app/pay/pay.php?a=h5_index" + s_field;
        dwc.GX_NetWorkManager.SendMessage(url,
            function (_msg) {
                cc.log(_msg);
                try {
                    var vecArg = _msg.split("|");
                    var retObj = JSON.parse(vecArg[1]);
                    var wxurl = retObj.payments[0].itemResponseMsg.wxurl;
                    var localUrl = retObj.payments[0].itemResponseMsg.localUrl;
                    if (cc.sys.isNative) {
                        cc.sys.openURL(localUrl);
                    }
                } catch (e) {
                    cc.log(e.name + " : " + e.message);
                }
            });
        return;
    },
    goto_h5_weixin_szhuyu : function(payment)
    {
        var id = payment["id"];
        var item_id = payment.item_id;
        var price  = payment.price;//以分计算

        var bundle = $.getBundleID();
        $.uid = dwc.Myself.GetData().GetUid();
        var order_no = $.uid + "_" + Date.now();
        var s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=ios";
        if (cc.sys.os == cc.sys.OS_ANDROID) {
            s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=android";
        }
        if (cc.sys.os == cc.sys.OS_IOS) {
            s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=ios";
        }
        //http://api.99epay.net/h5Pay/order/mkH5Order.htm
        //http://api.99epay.net/mctrpc/order/mkReceiptOrder.htm
        //http://zjmj.cjpoker.com/app/h5pay.php",
        var url = "http://zjmj.cjpoker.com/app/pay/pay.php?a=h5_index_weixin_szhuyu" + s_field;

        dwc.GX_NetWorkManager.SendMessage(url,
            function (_msg) {
                cc.log(_msg);
                try {
                    var _msg = JSON.parse(_msg);
                    var retObj = _msg.data;
                    var localUrl = retObj.payInfo;
                    if (cc.sys.isNative) {
                        cc.sys.openURL(localUrl);
                    }
                } catch (e) {
                    cc.log(e.name + " : " + e.message);
                }
            });
        return;
    },

    goto_h5_alipay_szhuyu : function(payment)
    {
        var id = payment["id"];
        var item_id = payment.item_id;
        var price  = payment.price;//以分计算

        var bundle = $.getBundleID();
        $.uid = dwc.Myself.GetData().GetUid();
        var order_no = $.uid + "_" + Date.now();
        var s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=ios";
        if (cc.sys.os == cc.sys.OS_ANDROID) {
            s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=android";
        }
        if (cc.sys.os == cc.sys.OS_IOS) {
            s_field = "&order_no=" + order_no + "&user=" + $.uid + "&to_user=" + $.uid + "&item_id=" + item_id + "&money=" + price + "&channel=h5" + "&bundle=" + bundle + "&platform=h5" + "&os=ios";
        }
        //http://api.99epay.net/h5Pay/order/mkH5Order.htm
        //http://api.99epay.net/mctrpc/order/mkReceiptOrder.htm
        //http://zjmj.cjpoker.com/app/h5pay.php",
        var url = "http://zjmj.cjpoker.com/app/pay/pay.php?a=h5_index_alipay_szhuyu" + s_field;
        if (cc.sys.isNative) {
            cc.sys.openURL(url);
        }
        cc.log(url);
    },
    goto_app_pingxx: function (payment,payMethod) {
        var that=this;
        $.setPayMethod(payMethod);

        var id = payment["id"];
        var item_id = payment.item_id;
        var price  = payment.price * 100;//ping++以分计算

        if(cc.sys.os == cc.sys.OS_ANDROID)
        {
            try {

                var UID = $.uid + "";
                var user = UID + "+" + payment.price;//+ %2B
                var to_user = UID;
                var money = price;
                var channel;
                if (payMethod == "AliPay") {
                    channel = "alipay";
                }
                if (payMethod == "WeChat") {
                    channel = "wx";
                }
                var bundleID = $.getBundleID();
                var allURL = "http://zjmj.cjpoker.com/app/pay/pay.php?platform=android&app=" +bundleID + "&user=" + user + "&to_user=" + to_user + "&money=" + money + "&channel=" + channel + "&item_id=" + item_id;
                dwc.GX_NetWorkManager.SendMessage(allURL,
                    function (_msg) {
                        jsb.reflection.callStaticMethod("org/cocos2dx/javascript/AppActivity", "GoToPay", "(Ljava/lang/String;)V", _msg);
                    });

            } catch (e) {
            }
        }
        if(cc.sys.os == cc.sys.OS_IOS)
        {
            try {
                var UID = $.uid + "";
                var user = UID + "+" + payment.price;//+ %2B
                var to_user = UID;
                var money = price;
                var channel;
                if (payMethod == "AliPay") {
                    channel = "alipay";
                }
                if (payMethod == "WeChat") {
                    channel = "wx";
                }
                var bundleID = $.getBundleID();
                var allURL = "http://zjmj.cjpoker.com/app/pay/pay.php?platform=ios&app=" +bundleID + "&user=" + user + "&to_user=" + to_user + "&money=" + money + "&channel=" + channel + "&item_id=" + item_id;
                dwc.GX_NetWorkManager.SendMessage(allURL,
                    function (_msg) {
                        if (cc.sys.os == cc.sys.OS_ANDROID) {
                            jsb.reflection.callStaticMethod("Pingpp","createPayment:appURLScheme:withCompletion:",_msg,"zjh");
                        } else if (cc.sys.os == cc.sys.OS_IOS) {
                            var bundle = $.getBundleID();
                            if(bundle == "cn.hynets.mgcs")
                            {
                                jsb.reflection.callStaticMethod("Pingpp","createPayment:appURLScheme:withCompletion:",_msg,"mgcs");
                            }else if(bundle == "cn.hynets.zjh")
                            {
                                jsb.reflection.callStaticMethod("Pingpp","createPayment:appURLScheme:withCompletion:",_msg,"zjh");
                            }else if(bundle == "com.cjpoker.zjh")
                            {
                                jsb.reflection.callStaticMethod("Pingpp","createPayment:appURLScheme:withCompletion:",_msg,"zjh");
                            }else if(bundle == "com.cjpoker.xlch")
                            {
                                jsb.reflection.callStaticMethod("Pingpp","createPayment:appURLScheme:withCompletion:",_msg,"xlch");
                            }else
                            {
                                jsb.reflection.callStaticMethod("Pingpp","createPayment:appURLScheme:withCompletion:",_msg,"zjh");
                            }
                        }

                    });
            } catch (e) {
            }
        }
    }
});

dwc.ShopGoodList = [
    {
        item_id : "ITEM_CARD_6",
        name : "4房卡",
        price : 6,
        giveExtra : "",

    },
    {
        item_id : "ITEM_CARD_12",
        name : "10房卡",
        price : 12,
        giveExtra : "",
    },
    {
        item_id : "ITEM_CARD_28",
        name : "28房卡",
        price : 28,
        giveExtra : "",
    },
    {
        item_id : "ITEM_CARD_68",
        name : "78房卡",
        price : 68,
        giveExtra : "",
    },
    {
        item_id : "ITEM_CARD_118",
        name : "158房卡",
        price : 118,
        giveExtra : "",
    },
    {
        item_id : "ITEM_CARD_328",
        name : "518房卡",
        price : 328,
        giveExtra : "",
    }
];